<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


   
   
    <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    

</head>

<body class="gray-bg">

	<div class="modal inmodal fade" id="myModal5" tabindex="-1"
		role="dialog" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
					<small class="font-bold">新增组 
				</div>
				<div class="modal-body">
					<form id="myform">
						<div>
							<label>名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称：</label><input type="text" name="groupName" />
						</div>
						<div>
							<label>说&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;明：</label><input type="text" name="groupDescribe" />
						</div>
						<div>
							<label>凭证规则：</label><select name="keyId" id="keyId" style="width: 168px;height: 25px"></select>
						</div>
						<div>
							<label>认证规则：</label><select name="ruleId" id="ruleId" style="width: 168px;height: 25px"></select>
						</div>
						<div>
							<label>路径规则：</label><select name="pathId" id="pathId" style="width: 168px;height: 25px"></select>
						</div>
					</form>
				</div>

				<div class="modal-footer">
					<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" id="saveButton">保存</button>
				</div>
			</div>
		</div>
	</div>

	<div class="wrapper wrapper-content animated fadeInRight">

        <!-- Panel Other -->
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <button value="新增" style="width: 60px;height: 30px"  data-toggle="modal" data-target="#myModal5">新增</button>
                <div class="ibox-tools">
                </div>
            </div>
            <div class="ibox-content">
                <div class="row row-lg">
                    <div class="col-sm-12">
                        <!-- Example Card View -->
                        <div class="example-wrap">
                            
                            <div class="example">
                                <table id="myTable" >
                                    
                                </table>
                            </div>
                        </div>
                        <!-- End Example Card View -->
                    </div>

                </div>
            </div>
        </div>
        <!-- End Panel Other -->
		
    </div>

    <!-- 全局js -->
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="js/content.js?v=1.0.0"></script>


    <!-- Bootstrap table -->
    <script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

    <script src="js/aivms5.js"></script>

<script>
var control_url = aivms5_control_url;
 $("#myTable").bootstrapTable({
        url:control_url + "/personGroup/list", 
        method:'post',
        cache:false,
        pagination:true,
        sortable:false,
        sidePagination:"client",
        pageNumber:1,
        pageSize:10,
        search:false,
        uniqueId:'id',
        showRefresh: false,
        queryParams: queryParams,//传递参数（*）
		contentType: "application/x-www-form-urlencoded",
		ajaxOptions:{
          headers: {"token":"aaaa"}
        },
        clickToSelect:true,
        columns:[
			{  
			    formatter: function (value, row, index) {  
			        return index+1;  
			    }  
			},
			{
                field:"checked",
                checkbox : true
            },
            {
			    field:"groupIdentifier",
			    title:"组标识"
			},
			{
			    field:"groupName",
			    title:"组名"
			},
			{
			    field:"keyName",
			    title:"凭证规则"
			},
			{
			    field:"ruleName",
			    title:"认证规则"
			},
			{
			    field:"pathName",
			    title:"路径规则"
			},
            {
                field:"groupDescribe",
                title:"组说明"
            },
			{
                field:"createdate",
                title:"创建时间"
            }
        
        ]
    });

	  function queryParams(params) {
        var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            limit: params.limit,   //页面大小
            offset: params.offset,  //页码
           
        };
        return temp;
       };
       
       
       $("#saveButton").click(function(){
       
       	var params = $("#myform").serialize();
               $.ajax( {  
                   type : "POST",  
                   url : control_url + "/personGroup/addOrUpdate",  
                   data : params,  
                   success : function(data) {  
                   	if(data.code == 1000)
                   	{
                   		$("#myModal5").modal("hide");
                   		$("#myTable").bootstrapTable('refresh');
                   	}
                   	else
                   	{
                   		alert(data.msg)
                   	}
                   },
                   error: function(XMLHttpRequest, textStatus, errorThrown) {
                       alert(XMLHttpRequest.status);
                       alert(XMLHttpRequest.readyState);
                       alert(textStatus);
                   }
               });  
       })//   
       
       
       $.ajax({
			type : "POST",
			url : control_url + "/key/list",
			success : function(data) {

					var value = "";
					for (var i = 0; i < data.length; i++) {
						var obj = data[i];
						value += "<option value='"+obj.id+"'>"+ obj.keyName + "</option>"
					}
					$("#keyId").append(value);
			},
			error : function(data) {
				alert(data);
			}
		});
       
       $.ajax({
			type : "POST",
			url : control_url + "/rule/list",
			success : function(data) {

					var value = "";
					for (var i = 0; i < data.length; i++) {
						var obj = data[i];
						value += "<option value='"+obj.id+"'>"+ obj.ruleName + "</option>"
					}
					$("#ruleId").append(value);
			},
			error : function(data) {
				alert(data);
			}
		});
       
       $.ajax({
			type : "POST",
			url : control_url + "/path/list",
			success : function(data) {

					var value = "";
					for (var i = 0; i < data.length; i++) {
						var obj = data[i];
						value += "<option value='"+obj.id+"'>"+ obj.pathName + "</option>"
					}
					$("#pathId").append(value);
			},
			error : function(data) {
				alert(data);
			}
		});
</script>

</body>

</html>
